package controllers

import (
	"github.com/astaxie/beego"
	//"fmt"
    "beego/testApp/common/exam"
	"beego/testApp/common/class"
	
	"beego/testApp/common/tool"
	"time"
)

type AddExamController struct {
	beego.Controller
}

func (c *AddExamController) Get() {

	cid,_  := c.GetInt("cid")
	ename := c.GetString("ename")

	if(cid != 0 && ename != ""){
		
	   now := time.Now()	
	   examobj := &exam.Exam{Ename:ename,Cid:cid,Created:now}
  
       tool.Pic("add exmam controller ",examobj)
	   exaddck := examobj.Add()
	   
	   if(exaddck == true ){
		   c.Redirect("/admin/classlist",301)
	   }
	}


	classobj := &class.Class{}

	classlist := classobj.GetClassList(0)
	
	
    c.Data["clist"] = classlist
	c.TplName = "addexam.html"

}
